//
// Created by xili on 2024/8/28 20:51.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution1 {
public:
    string removeOccurrences(string s, string part) {
        string stk;
        int n = part.size();
        for (auto &item: s) {
            stk.push_back(item);
            if (stk.size() >= n && stk.substr(stk.size() - n, n) == part) {
                stk.erase(stk.end() - n, stk.end());
            }
        }
        return stk;
    }
};

class Solution2 {
public:
    string removeOccurrences(string s, string t) {
        int c = 0, n = t.size();
        while ((c = s.find(t)) != string::npos) {
            s.erase(c, n);
        }
        return s;
    }
};